
/*
*Released on 28th June 2008.
*Any violations can be reported at paritosh@wikiocean.net
*What is treated as violations can be found at www.wikiocean.net/ppl1-voilations*
******************************************************************************
* The contents of this file are subject to POOL Public License 1.0 and later.
* POOL Public License is based on Affero GPL v3 and additional conditions.
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the Affero GPL v3 License at http://www.gnu.org/licenses/agpl.html
* You may obtain a copy of the POOL Public License 1.0 or later at www.wikiocean.net/license/ppl.html
* Software distributed under POOL Public License 1.0 is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Initial Developer of the Original Code is Paritosh Pungaliya (C) 2008. All Rights Reserved.
******************************************************************************
* Objective of the additional terms (license)
* 1) Is to extend the software freedom to freedom to work.
* 2) To ensure that knowledge is free from monopoly of agencies.
* 3) To avoid a situation where big corporate or investor can buy out free software groups and companies and then start milking the communities built around it.
* (this trend can be seen how the freedom is curtailed in companies that get Venture Capital funding.)
******************************************************************************
*/

package  logicalOperation;

import java.util.Vector;

import logger.PoolLogger;
import dbmanager.DBManager;

public class Or implements Logicaloperation
{
	int index;
	PoolLogger pl;
	
	public Or() {
		// logger
		pl = (PoolLogger) PoolLogger.getLogger(this.getClass().getName());
	}
	
	public void searchColumn(int index) 
	{
		this.index = index;
	}
	public String[] getResult(String[] string1, String[] string2) 
	{
		Vector<Object> Result = new Vector<Object>();
		
		String[] str1 = getRecordOfSearchColumn(string1);
		String[] str2 = getRecordOfSearchColumn(string2);
		Result.add(string1[0]);
		
		boolean FLAG = false;
		for(int i=1;i<str1.length;i++)
		{
			for(int j=1;j<str2.length;j++)
			{
				if(str1[i].equals(str2[j]))
				{
					FLAG = true;
					break;
				}
				else
					FLAG = false;
			}
			if(FLAG==false)
				Result.add(string1[i]);
		}
		for(int i=1; i<str2.length;i++)
			Result.add(string2[i]);
		String[] temp = new String[Result.size()];
		Result.toArray(temp);
		return temp;
	}
	
	String [] getRecordOfSearchColumn(String [] str)
	{
		Vector<Object> Result = new Vector<Object>();
		for(int i=0;i<str.length;i++)
		{
			String [] tempstr = str[i].split("\t");
			Result.add(tempstr[index]);
		}
		String[] temp = new String[Result.size()];
		Result.toArray(temp);
		return temp;
	}
	
	public static void main(String []a)
	{
		String string1 []= {"111\t123\t124","113\t123\t124","117\t123\t126"};
		String string2 []= {"111\t125\t126","113\t125\t127","112\t125\t128"};
		Or or = new Or();
		or.searchColumn(0);
		String [] temp = or.getResult(string1, string2);
		for(int i=0;i<temp.length;i++)
			System.out.println(temp[i]);
	}
	public void searchColumn(int index, int index1) {
		// TODO Auto-generated method stub
		
	}
	public boolean getResult(boolean string1, boolean string2) {
		// TODO Auto-generated method stub
		return false;
	}
}